#!/bin/bash
#
# The essential directories for the proper functioning of charm++ is
# usually linked to the latest build version. For the convenience of
# users wishing to alternate between different builds of charm++,
# a simple script has been provided.
#
# Usage: relink.script <build-version-name-string>
#
# Example: relink.script netlrts-linux-i386-smp.
# by Chee Wai Lee	10/13/2003
#
# rewritten by
# Gengbin Zheng		01/15/2004
#
# modified by
# Abhinav Bhatele	11/06/2007

if test ! -d "$1"
then
 echo "$0 <directory>" && exit 1
fi

subdirs="bin include lib lib_so tmp"

# remove symbolic link
# shellcheck disable=SC2086
rm -f $subdirs

for i in $subdirs
do
# skip nonexistent subdir
  test ! -d "$1/$i" && continue;
  echo ln -s "$1/$i" "$i"
  ln -s "$1/$i" "$i"
done

rm -f charm-version.h

if test -f "$1/include/charm-version.h"
then
  echo ln -s "$1/include/charm-version.h" charm-version.h
  ln -s "$1/include/charm-version.h" charm-version.h
fi
